package analyzeLogFiles;

import java.util.ArrayList;

/**
 * ConnectionObject handles storing a single current "active" connection for
 * 		the AnalyzeLogLine class.
 * @author Gabrielle DuBois
 *
 */
class ConnectionObject {
	private int dbID;
	private String UID;
	private String server;

	private boolean sawIP;

	//Keeps track of any timeStamps or visualizations names which can't be
	//written out to database yet because having seen the IP Address
	private ArrayList<String> timeVisual;

	/**
 	  * Constructor
 	  * @param serverName the String containing the name of the sever where the
 	  		connection occured
 	  * @param userID the String from the log file which uniquely identifies
 	  		a connected user for a particular log file
 	  */
    public ConnectionObject(String serverName, String userID){
		server = serverName;
		UID = userID;

		sawIP = false;
		timeVisual = new ArrayList<String>();
    }//constructor

	/**
 	  * Returns the database id assoicated with this connection object
 	  * @return a String containing the auto id originally generated by the
 	  			database.
 	  */
    public int getDatabaseID(){
		return dbID;
    }//getDatabaseID()

	/**
 	  * Sets the database id assoicated with this connection object
 	  * @param databaseID
 	  */
    public void setDatabaseID(int databaseID){
		dbID = databaseID;
    }//setDatabaseID()

    /**
 	  * Gets the string value of the user id associated with this
 	  * 	connection object
 	  * @return a String
 	  */
    public String getUserID(){
		return UID;
    }//getUserID()

    /**
 	  * Gets the string value of the server name associated with this
 	  *		connection object
 	  * @return a String containing the name of the server
 	  */
    public String getServerName(){
		return server;
    }//getServerName()

    /**
 	  * Keeps track of if the IP address for this connection object has been
 	  *			seen and returns a list of timestamps/visualizations which
 	  *			were stored up and can now be written out to the database
 	  * @param didSeeIPAddress is a boolean representing if the IP address
 	  * 			has been seen
 	  * @return If the IP address has been seen then this returns
 	  * 			an ArrayList<String> containing all the timeStamps and
 	  *				visualizations which can now be written out to the database
 	  *				in the format of first timestamp then viusalization name.
 	  *				Else returns a empty ArrayList<String>.
 	  */
    public ArrayList<String> setSawIP(boolean didSeeIPAddress){
		sawIP = didSeeIPAddress;
		if (sawIP)
			return timeVisual;
		return new ArrayList<String>();
    }//setSawIP()

    /**
 	  * Gets the boolean value of if the IP address as been encountered for
 	  *			this connection object
 	  * @return a boolean denoting if the IP address was already seen
 	  */
    public boolean getSawIP(){
		return sawIP;
    }//getSawIP()

}//ConnectionObject
